<?php

session_start();
$username=$_SESSION['username'];

$mysql =new mysqli("localhost","root","","pengdandan");


$sql = "SELECT * FROM heibing WHERE username ='$username'";

//验证
$result =$mysql->query($sql);

// if ($result) {
//   echo "正确";
// }else {
//   echo "错误";
// }
// var_dump($result);

//num_rows 查询返回的记录数
if($result->num_rows) {

  //如果查到东西了
  //转换成关联数组
    $arr = array();
   while ($result2=$result->fetch_assoc()) {


       array_push($arr,$result2);

   }


    $str= json_encode($arr);

    echo "$str";


}
//提前清除查询结果
//$mysql->free_result();





$mysql->close();

















 ?>
